<template>
  <page-meta :page-style="$theme.pageStyle">
    <!-- #ifndef H5 -->
    <navigation-bar
        :front-color="$theme.navColor"
        :background-color="$theme.navBgColor"
    />
    <!-- #endif -->
  </page-meta>
  <view class="index" :style="pageStyle">
    <page-bg></page-bg>

    <!--顶部-->
    <u-navbar
        :safeAreaInsetTop="false"
        :placeholder="false"
        :is-back="true"
        :is-fixed="true"
        :title="'我的牵线'"
        :border-bottom="false"
        :title-bold="true"
        :title-color="'#111111'"
        :background="{ background : navBg }"
    >
    </u-navbar>

    <view class="page-card">
      <view class="card-user">
        <view class="user-left">
          <image class="left-pic" mode="aspectFit" src="/static/images/user/default_avatar.png"></image>
          <view class="left-data">
            <view class="data-title">
              您的牵线剩余次数
            </view>
            <view class="data-time">
              有效期至：2024-05-23
            </view>
          </view>
        </view>
        <view class="user-right">
          <view class="right-number">
            2
          </view>
          <view class="right-text">
            次
          </view>
        </view>
      </view>
      <view class="card-bottom">
        <view class="bottom-btn">
          <view class="btn-title">
            <view class="title-text">
              开通VIP会员
            </view>
            <u-icon name="arrow-right" size="30rpx" color="#fff"></u-icon>
          </view>
          <view class="btn-tip">
            获赠牵线次数
          </view>
        </view>
        <view class="bottom-btn" @click="navTo('/packagesA/pages/pullTheWirePackage/pullTheWirePackage')">
          <view class="btn-title">
            <view class="title-text">
              牵线服务套餐
            </view>
            <u-icon name="arrow-right" size="30rpx" color="#fff"></u-icon>
          </view>
          <view class="btn-tip">
            单独购买更享优惠
          </view>
        </view>
      </view>
    </view>

    <view class="px-[30rpx] mt-3">
      <tabs
          :current="navCurrent"
          @change="navChange"
          bar-width="60"
          :isScroll="false"
          :activeColor="'#111'"
          :bgColor="'transparent'"
          :stickyBgColor="'transparent'"
          :fontSize="36"
          :bold="true"
          :inactiveColor="'#888'"
          :barStyle="{
          bottom: '-8rpx',
          height: '8rpx',
          borderRadius: '8rpx',
          backgroundColor: 'transparent',
          backgroundImage: 'linear-gradient(to right, var(--color-primary), var(--color-minor))'
        }"
      >
        <tab v-for="(item, i) in navList" :key="i" :name="item.name"></tab>
      </tabs>
      <view class="mt-3">
        <view class="page-list">
          <view class="list-child" v-for="item of 5">
            <view class="child-item">
              <view class="item-time">
                申请时间：2024-04-22
              </view>
              <view class="item-box">
                <view class="box-user">
                  <image class="user-pic" mode="aspectFit" src="/static/images/user/default_avatar.png"></image>
                  <view class="user-data">
                    <view class="data-name">
                      <view class="name-text">小萌新</view>
                      <view class="name-sex">
                        <u-icon class="sex-icon" size="22rpx" color="#fff" name="woman"></u-icon>
                      </view>
                    </view>
                    <view class="data-id">
                      ID：542345345
                    </view>
                  </view>
                  <view class="user-btn">
                       等待连线
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>

  </view>
</template>

<script setup lang="ts">
import {computed, reactive, ref} from 'vue'
import {onPageScroll} from "@dcloudio/uni-app";

const navBg = ref<string>('rgba(255,255,255,0)')

onPageScroll((event: any) => {
  navBg.value = event.scrollTop > 10 ? '#fff' : 'rgba(255,255,255,0)'
})

const navTo = (url: any) => {
  uni.navigateTo({url})
}

const navCurrent = ref(0)
const navList = ref([
  {
    name: '我申请的牵线',
    id: '',
  },
  {
    name: '向我申请的牵线',
    id: 1,
  }
])


const navChange = (item: any) => {
  console.log('item', item)
}

</script>

<style lang="scss" scoped>
.index {
  padding-bottom: 60rpx;
  position: relative;
  background-repeat: no-repeat;
  background-size: 100% auto;
  overflow: hidden;
  width: 100%;
  transition: all 1s;
  min-height: calc(100vh - env(safe-area-inset-bottom));
}


.page-card {
  width: calc(100% - 60rpx);
  margin: 0 auto;
  border-radius: 30rpx;
  padding: 30rpx;
  background: linear-gradient(158deg, var(--color-primary) 26%, var(--color-minor) 83%);
  box-shadow: inset 0px 4px 10px 0px rgba(255, 255, 255, 0.4);

  .card-user {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .user-left {
      display: flex;
      align-items: center;
      justify-content: flex-start;

      .left-pic {
        flex-shrink: 0;
        width: 130rpx;
        height: 130rpx;
        border-radius: 50%;
        border: 2rpx;
        margin-right: 20rpx;
      }

      .left-data {
        font-size: 28rpx;
        color: #C0ADFA;

        .data-title {
          margin-bottom: 10rpx;
          font-size: 30rpx;
          color: #ffffff;
          font-weight: bold;
        }
      }
    }

    .user-right {
      flex-shrink: 0;
      display: flex;
      align-items: flex-end;
      justify-content: flex-end;
      color: #fff;
      font-size: 28rpx;

      .right-number {
        font-size: 60rpx;
        font-weight: bold;
        margin-bottom: -14rpx;
      }
    }
  }

  .card-bottom {
    margin-top: 30rpx;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20rpx;

    .bottom-btn {
      padding: 30rpx;
      background-color: rgba(255, 255, 255, .3);
      border-radius: 30rpx;

      .btn-title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 32rpx;
        color: #ffffff;
        font-weight: bold;
      }

      .btn-tip {
        color: #ffffff;
        font-size: 24rpx;
        opacity: 0.8;
      }
    }
  }
}

.page-list {
  padding: 30rpx;
  background-color: #ffffff;
  border-radius: 30rpx;
  .list-child {
    &:first-child {
      .child-item {
        .item-time {
          &:after {
            height: 50%;
          }
        }
      }
    }
    .child-item {
      .item-time {
        padding-left: 30rpx;
        font-size: 28rpx;
        color: #999999;
        position: relative;
        z-index: 1;
        &:before {
          content: '';
          width: 16rpx;
          height: 16rpx;
          background-color: var(--color-primary);
          border-radius: 50%;
          position: absolute;
          left: 0;
          top: 50%;
          transform: translate(-50%,-50%);
          z-index: 1;
        }
        &:after {
          content: '';
          width: 2rpx;
          height: 100%;
          background-color: #D8D8D8;
          border-radius: 50%;
          position: absolute;
          left: 0;
          bottom: 0;
          transform: translate(-50%);
          z-index: 0;
        }
      }
      .item-box {
        padding-left: 30rpx;
        position: relative;
        z-index: 0;
        padding-top: 20rpx;
        padding-bottom: 30rpx;
        &:before {
          content: '';
          width: 2rpx;
          height: 100%;
          background-color: #D8D8D8;
          border-radius: 50%;
          position: absolute;
          left: 0;
          top: 50%;
          transform: translate(-50%,-50%);
        }
        .box-user {
          padding: 30rpx;
          background-color: #F3F8FE;
          display: flex;
          align-items: center;
          justify-content: space-between;
          border-radius: 20rpx;
          .user-pic {
            flex-shrink: 0;
            width: 80rpx;
            height: 80rpx;
            border-radius: 50%;
          }
          .user-data {
            width: 100%;
            margin-left: 20rpx;
            .data-name {
              display: flex;
              align-items: center;
              justify-content: flex-start;
              .name-text {
                font-size: 28rpx;
                color: #111111;
                font-weight: bold;
              }
              .name-sex {
                transform: rotate(45deg);
                background-color: #FF668A;
                width: 30rpx;
                height: 30rpx;
                border-radius: 50%;
                display: flex;
                align-items: center;
                justify-content: center;
                flex-shrink: 0;
                text-align: center;
                margin-left: 10rpx;
                margin-bottom: 10rpx;

                .sex-icon {
                  display: inline-block;
                  margin-left: 2rpx;
                }
              }
            }
            .data-id {
              font-size: 24rpx;
              color: #999999;
            }
          }
          .user-btn{
            flex-shrink: 0;
            padding: 10rpx 20rpx;
            border-radius: 30rpx;
            border: 2rpx solid var(--color-primary);
            font-size: 28rpx;
            color: var(--color-primary);
          }
        }
      }
    }
  }
}
</style>
